﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Wpf.Ui.Controls;assembly=Wpf.Ui"
    xmlns:navigation="clr-namespace:Wpf.Ui.Controls.Navigation;assembly=Wpf.Ui">

    <!--  ReSharper disable Xaml.StaticResourceNotResolved  -->

    <!--
        NavigationStoreItem that can accomodate slightly longer text.
        Delete me when fixed in upstream Wpf.Ui
    -->
    <Style x:Key="NavigationStoreItem" TargetType="{x:Type controls:NavigationItem}">
        <Setter Property="MinWidth" Value="60" />
        <Setter Property="MaxWidth" Value="80" />
        <Setter Property="MinHeight" Value="60" />
        <Setter Property="Margin" Value="0,0,0,4" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="IconSize" Value="24" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource TextFillColorSecondary}" />
            </Setter.Value>
        </Setter>
        <Setter Property="IconForeground">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource TextFillColorSecondary}" />
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <SolidColorBrush Opacity="0.0" Color="{DynamicResource ControlStrokeColorDefault}" />
            </Setter.Value>
        </Setter>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
        <Setter Property="KeyboardNavigation.IsTabStop" Value="True" />
        <Setter Property="Focusable" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:NavigationItem}">
                    <Border
                        x:Name="MainBorder"
                        Padding="4"
                        HorizontalAlignment="Stretch"
                        Background="Transparent"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="1"
                        CornerRadius="4">
                        <Grid>
                            <Rectangle
                                x:Name="ActiveRectangle"
                                Width="4"
                                Height="24"
                                Margin="-4,0,0,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Opacity="0.0"
                                RadiusX="2"
                                RadiusY="2">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <Grid HorizontalAlignment="Stretch">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <controls:SymbolIcon
                                    x:Name="ElementIcon"
                                    Grid.Row="0"
                                    Margin="0"
                                    FontSize="{TemplateBinding IconSize}"
                                    Foreground="{TemplateBinding IconForeground}"
                                    Symbol="{TemplateBinding Icon}" />

                                <Image
                                    x:Name="ElementImage"
                                    Grid.Row="0"
                                    Width="24"
                                    Margin="0"
                                    RenderOptions.BitmapScalingMode="HighQuality"
                                    Source="{TemplateBinding Image}" />

                                <Grid
                                    x:Name="ContentGrid"
                                    Grid.Row="1"
                                    Margin="0,2,0,0">
                                    <ContentPresenter x:Name="ElementContentPresenter" HorizontalAlignment="Center">
                                        <ContentPresenter.Content>
                                            <TextBlock
                                                FontSize="10"
                                                Foreground="{TemplateBinding Foreground}"
                                                Text="{TemplateBinding Content}"
                                                TextAlignment="Center"
                                                TextWrapping="Wrap" />
                                        </ContentPresenter.Content>
                                    </ContentPresenter>
                                </Grid>
                            </Grid>
                        </Grid>

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="True">
                            <Setter TargetName="ActiveRectangle" Property="Opacity" Value="1.0" />
                            <Setter TargetName="ElementIcon" Property="Filled" Value="True" />
                            <Setter TargetName="MainBorder" Property="Background">
                                <Setter.Value>
                                    <SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ElementIcon" Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ElementContentPresenter" Property="Margin" Value="0" />
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentGrid"
                                            Storyboard.TargetProperty="MaxHeight"
                                            From="30"
                                            To="0"
                                            Duration="0:0:.16" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentGrid"
                                            Storyboard.TargetProperty="Opacity"
                                            From="1"
                                            To="0"
                                            Duration="0:0:.16" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="MainBorder"
                                            Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Opacity)"
                                            From="0"
                                            To="1"
                                            Duration="0:0:.16" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentGrid"
                                            Storyboard.TargetProperty="MaxHeight"
                                            From="0"
                                            To="30"
                                            Duration="0:0:.16" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentGrid"
                                            Storyboard.TargetProperty="Opacity"
                                            From="0"
                                            To="1"
                                            Duration="0:0:.16" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="MainBorder"
                                            Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Opacity)"
                                            From="1"
                                            To="0"
                                            Duration="0:0:.16" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="Icon" Value="Empty">
                            <Setter TargetName="ElementIcon" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="Image" Value="{x:Null}">
                            <Setter TargetName="ElementImage" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="MainBorder" Property="Background">
                                <Setter.Value>
                                    <SolidColorBrush Opacity="0.5" Color="{DynamicResource ControlFillColorDefault}" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsActive" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="ElementIcon" Property="Foreground">
                                    <Setter.Value>
                                        <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
                                    </Setter.Value>
                                </Setter>
                                <Setter TargetName="ContentGrid" Property="TextElement.Foreground">
                                    <Setter.Value>
                                        <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
                                    </Setter.Value>
                                </Setter>
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <!--
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsActive" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="MainBorder" Property="Background" Value="{DynamicResource ControlFillColorDefault}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsActive" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="MainBorder" Property="Background" Value="{DynamicResource ControlFillColorDefault}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        -->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type controls:NavigationStore}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="MinWidth" Value="60" />
        <Setter Property="MaxWidth" Value="80" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:NavigationStore}">
                    <controls:DynamicScrollViewer
                        Margin="0"
                        Padding="0"
                        HorizontalScrollBarVisibility="Disabled">
                        <Grid HorizontalAlignment="Left">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <ItemsControl
                                Grid.Row="0"
                                MinWidth="60"
                                MaxWidth="80"
                                Focusable="False"
                                ItemsSource="{TemplateBinding Items}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel
                                            MinWidth="0"
                                            Margin="0"
                                            HorizontalAlignment="Left" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>

                            <ItemsControl
                                Grid.Row="1"
                                Focusable="False"
                                ItemsSource="{TemplateBinding Footer}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel
                                            MinWidth="0"
                                            Margin="0"
                                            HorizontalAlignment="Left" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </Grid>
                    </controls:DynamicScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Resources>
            <Style BasedOn="{StaticResource NavigationStoreItem}" TargetType="{x:Type controls:NavigationItem}" />
            <Style BasedOn="{StaticResource NavigationStoreHeader}" TargetType="{x:Type navigation:NavigationHeader}" />
        </Style.Resources>
    </Style>

    <!--  ReSharper restore Xaml.StaticResourceNotResolved  -->

</ResourceDictionary>